package com.ctgu.rabbitmq.rabbitmq.lazyQueue;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ ClassName lazyQueueConfig
 * @ Author Alex2
 * @ Date 2025/9/1 11:35
 **/
@Configuration
public class LazyQueueConfig {

    public static final String LAZY_QUEUE = "lazy.queue";
    public static final String LAZY_EXCHANGE = "lazy.exchange";
    public static final String LAZY_ROUTING_KEY = "lazy.key";

    @Bean
    public Queue lazyQueue() {
        return QueueBuilder.durable(LAZY_QUEUE).lazy().build();
    }

    @Bean
    public DirectExchange lazyExchange() {
        return new DirectExchange(LAZY_EXCHANGE, true, false);
    }

    @Bean
    public Binding bindingLazyQueue() {
        return BindingBuilder.bind(lazyQueue())
                .to(lazyExchange())
                .with(LAZY_ROUTING_KEY);
    }
}